﻿using System;

namespace JTLeigh.Commerce.Spencer.Core.Common.Services
{

	/// <summary>
	/// Service used to handle exceptions.
	/// </summary>
	public interface IExceptionHandlingService
	{

		#region Methods

		/// <summary>
		/// Handles the specified exception and returns a value indicating whether or not it should
		/// be rethrown.
		/// </summary>
		/// <param name="tenantId">The tenant identifier <see cref="Guid"/> of the tenant who the
		/// exception is to be handled for.</param>
		/// <param name="exception">The <see cref="Exception"/> to handle.</param>
		/// <param name="exceptionPolicyKey">The exception policy key <see cref="String"/> used to
		/// identify the exception policy to use.</param>
		/// <returns><see langword="true"/> if the exception should be rethrown, 
		/// <see langword="false"/> otherwise.</returns>
		/// <remarks>
		/// <para>
		/// Most consumers should ignore the return value of this function and always rethrow the
		/// exception.  The few consumers that should honor the return value are those that can 
		/// simply swallow the exception without resulting in unexpected or unwanted behavior.
		/// </para>
		/// </remarks>
		bool HandleException(Guid tenantId, Exception exception, string exceptionPolicyKey);

		#endregion // Methods

	}

}
